package com.atguigu.controller;

import com.atguigu.pojo.Fruit;
import com.atguigu.service.FruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/fruit")
public class FruitController {
    @Autowired
    FruitService fruitService;

    @RequestMapping("/list")
    public List<Fruit> getFruit() {
        return fruitService.getFruits();
    }

    @GetMapping("/id")
    public Fruit getFruitById(@RequestParam int id) {
        return fruitService.getFruit(id);
    }
}
